<template>
  <div>
    <router-link to="/index"></router-link>
    <div id="box">
      <!-- 最顶端部分 -->
      <v-header title="手机注册"></v-header>
      <!-- 中间部分 -->
      <div id="center1">
        <img :src="require('../../assets/images/logo1.png')" alt="" />
          <div>
            <input
              type="text"
              name=""
              id=""
              placeholder="手机号"
              v-model="user.phone"
            />
          </div>
          <div class="nc">
            <input
              type="text"
              name=""
              id=""
              placeholder="昵称"
              v-model="user.nickname"
            />
          </div>
          <div class="yzm">
            <input
              type="text"
              name=""
              id=""
              placeholder="密码"
              v-model="user.password"
            />
          </div>
          <input type="submit" value="点我注册" class="in1" @click="register" />
      </div>

      <!-- 底部内容 -->
      <div id="bottom1">
        <p></p>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      user: {
        phone: "",
        nickname: "",
        password: "",
      },
    };
  },
  methods: {
    register() {
      if (
        this.user.phone === "" ||
        this.user.nickname === "" ||
        this.password == ""
      ) {
        alert("所有都不能为空");
        return;
      }
      axios({
        url: "/api/register",
        method: "post",
        data: this.user,
      }).then((res) => {
        alert(res.data.msg);
        if (res.data.code == 200) {
          this.$router.replace("/login");
        }
      });
    },
  },
};
</script>

<style scoped>
html,
body,
#box {
  height: 100%;
}
#box {
  max-width: 7.5rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}
/*最顶部部分*/
#top1 {
  width: 7.5rem;
  display: flex;
  height: 0.62rem;
  background-color: #ff6040;
  padding: 0.43rem 0 0.3rem 0;
  align-items: center;
  color: #ffdfd8;
}
#top1 .iconfont {
  font-size: 0.34rem;
}
#top1 i {
  margin-left: 0.33rem;
  margin-right: 2.4rem;
}
#top1 h2 {
  font-size: 0.3rem;
  margin-right: 1.2rem;
}
#top1 p {
  border: 1px solid #ff8a6f;
  display: flex;
  border-radius: 0.4rem;
  position: relative;
}
#top1 p span {
  width: 0.86rem;
  height: 0.6rem;
  line-height: 0.6rem;
  text-align: center;
}
#top1 p em {
  width: 1px;
  height: 0.37rem;
  background-color: #ff896e;
  position: absolute;
  left: 0.86rem;
  top: 0.12rem;
}
/*中间部分*/
#center1 {
  width: 7.12rem;
  background: #fff;
  flex: 1;
  margin: 0.2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-top: 2.5rem;
}
#center1 img {
  margin-bottom: 0.5rem;
  margin-top: 0.5rem;
  width: 3.64rem;
}
#center1 input {
  width: 6.12rem;
  height: 0.84rem;
  border: none;
  color: #8b8b8b;
}
#center1 form {
  text-align: center;
}
#center1 form div {
  border-bottom: 1px solid #f7f7f7;
  width: 6.1rem;
}
#center1 form .yzm {
  display: flex;
  justify-content: space-between;
}
#center1 form .yzm span {
  background: #ccc;
  color: #e9e9e9;
  width: 1.7rem;
  height: 0.25rem;
  line-height: 0.25rem;
  padding: 0.2rem 0.2rem;
  margin-top: 0.1rem;
  position: absolute;
  right: 0.7rem;
}
#center1 .in1 {
  margin-top: 0.4rem;
  color: #fff;
  background: #ff4400;
  border: none;
  margin-bottom: 10px;
}
/*底部部分*/
#bottom1 {
  position: fixed;
  transform: translate(-50%, -50%);
  left: 50%;
  bottom: 0.1rem;
}
#bottom1 p {
  width: 2.68rem;
  height: 0.1rem;
  background: #000;
  border-radius: 0.2rem;
}
</style>